/**
 * @Name ListViewTextCaseInsensitiveSorter.cs
 * @Purpose Implements text case-insensitive sorting
 * @Date 19 April 2005, 08:03:20
 * @Author S.Deckers 
 * @Description
 */

namespace ui.listview.sorter
{
	#region -- Using directives --
	using System;
	using System.Windows.Forms;
	using d = System.Diagnostics.Debug;
	#endregion

	/// <summary date="16-04-2005, 22:04:24" author="S.Deckers">
	/// Implements Text case-insensitive sorting
	/// </summary>
	class ListViewTextCaseInsensitiveSorter : ListViewSorter
	{
		/// <summary>
		/// Sorting implementation
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		/// <returns></returns>
		public override int OnSort(object x, object y, System.Windows.Forms.SortOrder sortOrder)
		{
			System.Windows.Forms.ListViewItem.ListViewSubItem left  = GetLeft( x);
			System.Windows.Forms.ListViewItem.ListViewSubItem right = GetLeft( y);

			int res = String.Compare( left.Text, right.Text, true);
			
			if( sortOrder == SortOrder.Descending)
			{
				res *= -1;
			}
			return( res);
		}
	}
}
